import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.util.Properties;

import org.apache.log4j.Logger;

import pl.piasecki.command.Do;

public class Main {
	private static Logger log = Logger.getLogger(Main.class);

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		String color = null;
		try {
			Properties properties = new Properties();
			properties.load(Main.class.getResourceAsStream("Main.properties"));
			color = properties.getProperty("color");
		} catch (IOException e) {
			log.error(e.getMessage(), e);
		}
		if (color != null) {
			try {
				Do _do = (Do) Class
						.forName("pl.piasecki.command." + color + ".Do")
						.getMethod("getInstance", (Class<Object>[]) null)
						.invoke(null, (Object[]) null);
				_do.execute();
			} catch (ClassNotFoundException e) {
				log.error(e.getMessage(), e);
			} catch (NoSuchMethodException e) {
				log.error(e.getMessage(), e);
			} catch (SecurityException e) {
				log.error(e.getMessage(), e);
			} catch (IllegalAccessException e) {
				log.error(e.getMessage(), e);
			} catch (IllegalArgumentException e) {
				log.error(e.getMessage(), e);
			} catch (InvocationTargetException e) {
				log.error(e.getMessage(), e);
			}
		}

	}
}
